{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import akshare as ak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "关键指标-新浪\n",
      "Index(['选项', '指标', '20240930', '20240630', '20240331', '20231231', '20230930',\n",
      "       '20230630', '20230331', '20221231', '20220930', '20220630', '20220331',\n",
      "       '20211231', '20210930', '20210630', '20210331', '20201231', '20200930',\n",
      "       '20200630', '20200331', '20191231', '20190930', '20190630', '20190331',\n",
      "       '20181231', '20180930', '20180630', '20180331', '20171231', '20170930',\n",
      "       '20170630', '20170331', '20161231', '20160930', '20160630', '20160331',\n",
      "       '20151231', '20150930', '20150630', '20150331', '20141231', '20140930',\n",
      "       '20140630', '20140331', '20131231', '20130930', '20130630', '20130331',\n",
      "       '20121231', '20120930', '20120630', '20120331', '20111231', '20110930',\n",
      "       '20110630', '20110331', '20101231', '20100930', '20100630', '20100331',\n",
      "       '20091231', '20090930', '20090630', '20090331', '20081231', '20080930',\n",
      "       '20071231', '20061231'],\n",
      "      dtype='object')\n",
      "      选项        指标      20240930      20240630      20240331      20231231  \\\n",
      "0   常用指标     归母净利润  8.578712e+09  7.947245e+09  6.055231e+09  1.001593e+10   \n",
      "1   常用指标     营业总收入  2.751648e+10  2.287575e+10  1.625488e+10  3.312628e+10   \n",
      "2   常用指标      营业成本  1.630549e+10  1.225810e+10  8.178616e+09  2.015110e+10   \n",
      "3   常用指标       净利润  8.575532e+09  7.947920e+09  6.052988e+09  1.002077e+10   \n",
      "4   常用指标     扣非净利润  8.397079e+09  7.941187e+09  6.050415e+09  9.842845e+09   \n",
      "..   ...       ...           ...           ...           ...           ...   \n",
      "74  营运能力    总资产周转率  4.108340e-01  3.452660e-01  2.286230e-01  4.809090e-01   \n",
      "75  营运能力   总资产周转天数  6.571986e+02  5.213360e+02  3.936597e+02  7.485815e+02   \n",
      "76  营运能力   流动资产周转率  5.547970e-01  4.654880e-01  3.027360e-01  6.367560e-01   \n",
      "77  营运能力  流动资产周转天数  4.866637e+02  3.866908e+02  2.972886e+02  5.653652e+02   \n",
      "78  营运能力   应付账款周转率  4.895169e+00  3.403636e+00  1.410141e+00  6.727296e+00   \n",
      "\n",
      "        20230930      20230630      20230331      20221231  ...      20100630  \\\n",
      "0   1.020347e+10  7.862381e+09  5.766048e+09  9.377865e+09  ...  1.067232e+09   \n",
      "1   3.028309e+10  2.187293e+10  1.504618e+10  3.010490e+10  ...  3.487100e+09   \n",
      "2   1.679753e+10  1.164555e+10  7.489139e+09  1.776576e+10  ...  2.052011e+09   \n",
      "3   1.022056e+10  7.873689e+09  5.776535e+09  9.389434e+09  ...  1.068576e+09   \n",
      "4   1.016498e+10  7.712986e+09  5.665647e+09  9.276678e+09  ...  1.071874e+09   \n",
      "..           ...           ...           ...           ...  ...           ...   \n",
      "74  4.573010e-01  3.403410e-01  2.228420e-01  4.434920e-01  ...  4.700380e-01   \n",
      "75  5.904583e+02  5.288805e+02  4.038976e+02  8.117907e+02  ...  3.829472e+02   \n",
      "76  6.123050e-01  4.602060e-01  2.966010e-01  5.945070e-01  ...  5.764230e-01   \n",
      "77  4.409566e+02  3.911284e+02  3.034375e+02  6.055436e+02  ...  3.122702e+02   \n",
      "78  4.881965e+00  3.203528e+00  1.673317e+00  6.078389e+00  ...  8.279597e+00   \n",
      "\n",
      "        20100331      20091231      20090930      20090630      20090331  \\\n",
      "0   7.214455e+08  1.253620e+09  9.038214e+08  5.883631e+08  3.631115e+08   \n",
      "1   1.933434e+09  4.002048e+09  2.892240e+09  1.804563e+09  1.102269e+09   \n",
      "2   9.714843e+08  2.337106e+09  1.690601e+09  1.029304e+09  6.219359e+08   \n",
      "3   7.214115e+08  1.253613e+09  9.038214e+08  5.883631e+08  3.631115e+08   \n",
      "4   7.206848e+08  1.243698e+09  8.978298e+08  5.811616e+08  3.631115e+08   \n",
      "..           ...           ...           ...           ...           ...   \n",
      "74  2.808070e-01  9.228270e-01  9.893930e-01  6.682710e-01           NaN   \n",
      "75  3.205041e+02  3.901053e+02  2.728945e+02  2.693517e+02           NaN   \n",
      "76  3.149810e-01  1.073961e+00  1.243208e+00  8.466540e-01           NaN   \n",
      "77  2.857309e+02  3.352074e+02  2.171799e+02  2.126015e+02           NaN   \n",
      "78  4.374946e+00  1.452690e+01  1.127972e+01  7.249451e+00           NaN   \n",
      "\n",
      "        20081231      20080930      20071231      20061231  \n",
      "0   7.430575e+08  5.665635e+08  3.747367e+08  1.749789e+08  \n",
      "1   2.682204e+09  2.048393e+09  1.762015e+09  1.071430e+09  \n",
      "2   1.684038e+09  1.285232e+09  1.176179e+09  7.920278e+08  \n",
      "3   7.430575e+08  5.665635e+08  3.748511e+08  1.749790e+08  \n",
      "4   7.408726e+08  5.665635e+08  3.747319e+08  1.756683e+08  \n",
      "..           ...           ...           ...           ...  \n",
      "74  1.468933e+00           NaN  1.406177e+00           NaN  \n",
      "75  2.450758e+02           NaN  2.560133e+02           NaN  \n",
      "76  1.919828e+00           NaN  1.898364e+00           NaN  \n",
      "77  1.875167e+02           NaN  1.896369e+02           NaN  \n",
      "78  1.471013e+01           NaN  1.245961e+01           NaN  \n",
      "\n",
      "[79 rows x 69 columns]\n"
     ]
    }
   ],
   "source": [
    "stock_financial_abstract_df = ak.stock_financial_abstract(symbol=\"002304\")\n",
    "print(\"关键指标-新浪\")\n",
    "print(stock_financial_abstract_df.keys())\n",
    "print(stock_financial_abstract_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception ignored in: <function tqdm.__del__ at 0x00000238E34AD990>\n",
      "Traceback (most recent call last):\n",
      "  File \"c:\\Users\\liufang\\.conda\\envs\\bt\\lib\\site-packages\\tqdm\\std.py\", line 1148, in __del__\n",
      "    self.close()\n",
      "  File \"c:\\Users\\liufang\\.conda\\envs\\bt\\lib\\site-packages\\tqdm\\notebook.py\", line 279, in close\n",
      "    self.disp(bar_style='danger', check_delay=False)\n",
      "AttributeError: 'tqdm_notebook' object has no attribute 'disp'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "关键指标-同花顺\n",
      "Index(['报告期', '净利润', '净利润同比增长率', '扣非净利润', '扣非净利润同比增长率', '营业总收入', '营业总收入同比增长率',\n",
      "       '基本每股收益', '每股净资产', '每股资本公积金', '每股未分配利润', '每股经营现金流', '销售净利率', '销售毛利率',\n",
      "       '净资产收益率', '净资产收益率-摊薄', '营业周期', '存货周转率', '存货周转天数', '应收账款周转天数', '流动比率',\n",
      "       '速动比率', '保守速动比率', '产权比率', '资产负债率'],\n",
      "      dtype='object')\n",
      "     报告期       净利润 净利润同比增长率   扣非净利润 扣非净利润同比增长率    营业总收入 营业总收入同比增长率  基本每股收益  \\\n",
      "0   2023   100.16亿    6.80%  98.43亿      6.10%  331.26亿     10.04%  6.6487   \n",
      "1   2022    93.78亿   24.91%  92.77亿     25.82%  301.05亿     18.76%  6.2252   \n",
      "2   2021    75.08亿    0.34%  73.73亿     30.44%  253.50亿     20.14%  5.0141   \n",
      "3   2020    74.82亿    1.35%  56.52亿    -13.79%  211.01亿     -8.76%  4.9843   \n",
      "4   2019    73.83亿   -9.02%  65.56亿    -11.04%  231.26亿     -4.28%  4.8991   \n",
      "5   2018    81.15亿   22.45%  73.69亿     20.09%  241.60亿     21.30%  5.3850   \n",
      "6   2017    66.27亿   13.73%  61.36亿     13.50%  199.18亿     15.92%  4.3976   \n",
      "7   2016    58.27亿    8.61%  54.07亿      9.98%  171.83亿      7.04%  3.8700   \n",
      "8   2015    53.65亿   19.03%  49.16亿     10.03%  160.52亿      9.41%  3.5600   \n",
      "9   2014    45.07亿   -9.89%  44.68亿    -10.43%  146.72亿     -2.34%  2.9900   \n",
      "10  2013    50.02亿  -18.72%  49.88亿    -17.28%  150.24亿    -13.01%  4.6300   \n",
      "11  2012    61.54亿   53.05%  60.30亿     50.65%  172.70亿     35.55%  5.7000   \n",
      "12  2011    40.21亿   82.39%  40.02亿     81.45%  127.41亿     67.22%  3.7200   \n",
      "13  2010    22.05亿   75.86%  22.06亿     77.36%   76.19亿     90.38%  2.4500   \n",
      "14  2009    12.54亿   68.71%  12.44亿     67.87%   40.02亿     49.21%  3.0400   \n",
      "15  2008     7.43亿   98.29%   7.41亿     97.71%   26.82亿     52.22%  1.8300   \n",
      "16  2007     3.75亿  114.16%   3.75亿    113.32%   17.62亿     64.45%  0.9300   \n",
      "17  2006     1.75亿  224.88%   1.76亿      False   10.71亿     56.71%  0.4600   \n",
      "18  2005  5386.00万    False   False      False    6.84亿      False   False   \n",
      "\n",
      "    每股净资产 每股资本公积金  ... 净资产收益率-摊薄    营业周期 存货周转率  存货周转天数 应收账款周转天数  流动比率  速动比率  \\\n",
      "0   34.48    0.62  ...    19.28%  805.45  0.45  805.19     0.26  3.06  1.89   \n",
      "1   31.50    0.60  ...    19.75%  813.29  0.44  813.01     0.28  2.58  1.69   \n",
      "2   28.19    0.52  ...    17.67%  910.97  0.40  910.93     0.04  2.01  1.33   \n",
      "3   25.54    0.49  ...    19.44%  901.07  0.40  900.90     0.17  2.54  1.51   \n",
      "4   24.23    0.49  ...    20.22%  769.56  0.47  769.40     0.17  2.29  1.39   \n",
      "5   22.33    0.49  ...    24.12%  758.16  0.47  758.05     0.10  2.30  0.25   \n",
      "6   19.59    0.49  ...    22.45%  675.98  0.53  675.80     0.17  2.12  0.15   \n",
      "7   17.29    0.49  ...    22.37%  677.64  0.53  677.46     0.18  2.04  0.22   \n",
      "8   15.22    0.49  ...    23.39%  624.74  0.58  624.57     0.18  2.03  0.46   \n",
      "9   18.32    1.09  ...    22.85%  588.52  0.61  588.14     0.38  1.86  0.52   \n",
      "10  16.10    1.23  ...    28.77%  446.03  0.81  445.10     0.92  1.63  0.78   \n",
      "11  13.61    1.23  ...    41.88%  278.82  1.30  277.86     0.96  1.79  1.07   \n",
      "12  10.99    1.67  ...    40.65%  192.27  1.88  191.31     0.96  1.63  1.13   \n",
      "13  15.38    5.68  ...    31.86%  151.97  2.39  150.58     1.38  2.41  1.89   \n",
      "14  11.28    5.68  ...    24.70%  164.79  2.20  163.41     1.38  4.58  3.75   \n",
      "15   3.41  0.0027  ...    53.73%  147.74  2.45  147.18     0.56  2.59  1.62   \n",
      "16   5.34    0.16  ...    51.99%  152.61  2.37  151.62     1.00  1.88  1.08   \n",
      "17   4.21    0.74  ...    46.20%  185.75  1.96  183.40     2.35  1.46  0.81   \n",
      "18  False    0.53  ...     False  294.96  1.24  290.44     4.52  1.04  0.54   \n",
      "\n",
      "   保守速动比率  产权比率   资产负债率  \n",
      "0    1.88  0.34  25.42%  \n",
      "1    1.66  0.43  30.07%  \n",
      "2    1.32  0.60  37.34%  \n",
      "3    1.51  0.40  28.58%  \n",
      "4    1.39  0.46  31.73%  \n",
      "5    0.25  0.47  32.16%  \n",
      "6    0.15  0.47  31.82%  \n",
      "7    0.22  0.49  32.90%  \n",
      "8    0.46  0.48  32.25%  \n",
      "9    0.52  0.46  31.40%  \n",
      "10   0.78  0.62  38.35%  \n",
      "11   1.07  0.61  37.82%  \n",
      "12   1.13  0.91  47.53%  \n",
      "13   1.89  0.59  35.65%  \n",
      "14   3.75  0.28  21.75%  \n",
      "15   1.62  0.58  36.65%  \n",
      "16   1.08  1.04  50.94%  \n",
      "17   0.81  1.74  63.47%  \n",
      "18   0.54  3.29  76.53%  \n",
      "\n",
      "[19 rows x 25 columns]\n"
     ]
    }
   ],
   "source": [
    "# indicator=\"按报告期\"; choice of {\"按报告期\", \"按年度\", \"按单季度\"}\n",
    "stock_financial_abstract_ths_df = ak.stock_financial_abstract_ths(symbol=\"002304\", indicator=\"按年度\")\n",
    "print(\"关键指标-同花顺\")\n",
    "print(stock_financial_abstract_ths_df.keys())\n",
    "print(stock_financial_abstract_ths_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "ename": "ImportError",
     "evalue": "IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mImportError\u001b[0m                               Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[8], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# 新浪财经-财务分析-财务指标\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m stock_financial_analysis_indicator_df \u001b[38;5;241m=\u001b[39m \u001b[43mak\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstock_financial_analysis_indicator\u001b[49m\u001b[43m(\u001b[49m\u001b[43msymbol\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m002304\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstart_year\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m2020\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;28mprint\u001b[39m(stock_financial_analysis_indicator_df)\n",
      "File \u001b[1;32mc:\\Users\\liufang\\.conda\\envs\\bt\\lib\\site-packages\\akshare\\stock_fundamental\\stock_finance.py:208\u001b[0m, in \u001b[0;36mstock_financial_analysis_indicator\u001b[1;34m(symbol, start_year)\u001b[0m\n\u001b[0;32m    206\u001b[0m out_df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mDataFrame()\n\u001b[0;32m    207\u001b[0m tqdm \u001b[38;5;241m=\u001b[39m get_tqdm()\n\u001b[1;32m--> 208\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m year_item \u001b[38;5;129;01min\u001b[39;00m \u001b[43mtqdm\u001b[49m\u001b[43m(\u001b[49m\u001b[43myear_list\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mleave\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m:\n\u001b[0;32m    209\u001b[0m     url \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m    210\u001b[0m         \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://money.finance.sina.com.cn/corp/go.php/vFD_FinancialGuideLine/\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m    211\u001b[0m         \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstockid/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00msymbol\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/ctrl/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00myear_item\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/displaytype/4.phtml\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m    212\u001b[0m     )\n\u001b[0;32m    213\u001b[0m     r \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(url)\n",
      "File \u001b[1;32mc:\\Users\\liufang\\.conda\\envs\\bt\\lib\\site-packages\\tqdm\\notebook.py:234\u001b[0m, in \u001b[0;36mtqdm_notebook.__init__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m    232\u001b[0m unit_scale \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39munit_scale \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39munit_scale \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;241m1\u001b[39m\n\u001b[0;32m    233\u001b[0m total \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtotal \u001b[38;5;241m*\u001b[39m unit_scale \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtotal \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtotal\n\u001b[1;32m--> 234\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcontainer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstatus_printer\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtotal\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdesc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mncols\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    235\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcontainer\u001b[38;5;241m.\u001b[39mpbar \u001b[38;5;241m=\u001b[39m proxy(\u001b[38;5;28mself\u001b[39m)\n\u001b[0;32m    236\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdisplayed \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
      "File \u001b[1;32mc:\\Users\\liufang\\.conda\\envs\\bt\\lib\\site-packages\\tqdm\\notebook.py:108\u001b[0m, in \u001b[0;36mtqdm_notebook.status_printer\u001b[1;34m(_, total, desc, ncols)\u001b[0m\n\u001b[0;32m     99\u001b[0m \u001b[38;5;66;03m# Fallback to text bar if there's no total\u001b[39;00m\n\u001b[0;32m    100\u001b[0m \u001b[38;5;66;03m# DEPRECATED: replaced with an 'info' style bar\u001b[39;00m\n\u001b[0;32m    101\u001b[0m \u001b[38;5;66;03m# if not total:\u001b[39;00m\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    105\u001b[0m \n\u001b[0;32m    106\u001b[0m \u001b[38;5;66;03m# Prepare IPython progress bar\u001b[39;00m\n\u001b[0;32m    107\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m IProgress \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:  \u001b[38;5;66;03m# #187 #451 #558 #872\u001b[39;00m\n\u001b[1;32m--> 108\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m(WARN_NOIPYW)\n\u001b[0;32m    109\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m total:\n\u001b[0;32m    110\u001b[0m     pbar \u001b[38;5;241m=\u001b[39m IProgress(\u001b[38;5;28mmin\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0\u001b[39m, \u001b[38;5;28mmax\u001b[39m\u001b[38;5;241m=\u001b[39mtotal)\n",
      "\u001b[1;31mImportError\u001b[0m: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html"
     ]
    }
   ],
   "source": [
    "# 新浪财经-财务分析-财务指标\n",
    "stock_financial_analysis_indicator_df = ak.stock_financial_analysis_indicator(symbol=\"002304\", start_year=\"2020\")\n",
    "print(stock_financial_analysis_indicator_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "个股估值\n",
      "Index(['数据日期', '当日收盘价', '当日涨跌幅', '总市值', '流通市值', '总股本', '流通股本', 'PE(TTM)',\n",
      "       'PE(静)', '市净率', 'PEG值', '市现率', '市销率'],\n",
      "      dtype='object')\n",
      "            数据日期   当日收盘价     当日涨跌幅     总市值    流通市值  总股本  流通股本    PE(TTM)  \\\n",
      "0     2018-01-02  116.00  0.869565  1748.0  1440.0   15    12  26.608725   \n",
      "1     2018-01-03  115.25 -0.646552  1736.0  1431.0   15    12  26.436686   \n",
      "2     2018-01-04  121.00  4.989154  1823.0  1503.0   15    12  27.755652   \n",
      "3     2018-01-05  122.98  1.636364  1853.0  1527.0   15    12  28.209836   \n",
      "4     2018-01-08  126.32  2.715889  1903.0  1569.0   15    12  28.975984   \n",
      "...          ...     ...       ...     ...     ...  ...   ...        ...   \n",
      "1754  2025-03-28   76.95 -0.478531  1159.0  1156.0   15    15  13.814631   \n",
      "1755  2025-03-31   76.25 -0.909682  1148.0  1145.0   15    15  13.688962   \n",
      "1756  2025-04-01   76.40  0.196721  1150.0  1148.0   15    15  13.715891   \n",
      "1757  2025-04-02   76.41  0.013089  1151.0  1148.0   15    15  13.717686   \n",
      "1758  2025-04-03   76.75  0.444968  1156.0  1153.0   15    15  13.778725   \n",
      "\n",
      "          PE(静)       市净率      PEG值        市现率       市销率  \n",
      "0     26.377867  5.922764  0.959375  28.268337  9.013478  \n",
      "1     26.207320  5.884470  0.953172  28.085568  8.955201  \n",
      "2     27.514844  6.178055  1.000728  29.486800  9.401990  \n",
      "3     27.965087  6.279151  1.017103  29.969311  9.555841  \n",
      "4     28.724588  6.449685  1.044727  30.783244  9.815367  \n",
      "...         ...       ...       ...        ...       ...  \n",
      "1754  11.573658  2.166901  2.130314  22.100969  3.818255  \n",
      "1755  11.468375  2.147189  2.110935  21.899920  3.783521  \n",
      "1756  11.490935  2.151413  2.115088  21.943002  3.790964  \n",
      "1757  11.492439  2.151695  2.115365  21.945874  3.791460  \n",
      "1758  11.543577  2.161269  2.124777  22.043526  3.808331  \n",
      "\n",
      "[1759 rows x 13 columns]\n"
     ]
    }
   ],
   "source": [
    "# 个股估值\n",
    "stock_value_em_df = ak.stock_value_em(symbol=\"002304\")\n",
    "print(\"个股估值\")\n",
    "print(stock_value_em_df.keys())\n",
    "stock_value_em_df[\"总市值\"] = stock_value_em_df[\"总市值\"] // 100000000\n",
    "stock_value_em_df[\"流通市值\"] = stock_value_em_df[\"流通市值\"] // 100000000\n",
    "stock_value_em_df[\"总股本\"] = stock_value_em_df[\"总股本\"] // 100000000\n",
    "stock_value_em_df[\"流通股本\"] = stock_value_em_df[\"流通股本\"] // 100000000\n",
    "print(stock_value_em_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A 股估值指标\n",
      "            date  value\n",
      "0     2022-04-06  27.50\n",
      "1     2022-04-07  27.57\n",
      "2     2022-04-08  27.49\n",
      "3     2022-04-09  27.49\n",
      "4     2022-04-10  27.49\n",
      "...          ...    ...\n",
      "1086  2025-03-27  13.88\n",
      "1087  2025-03-28  13.81\n",
      "1088  2025-03-29  13.81\n",
      "1089  2025-03-30  13.81\n",
      "1090  2025-03-31  13.69\n",
      "\n",
      "[1091 rows x 2 columns]\n"
     ]
    }
   ],
   "source": [
    "# A 股估值指标\n",
    "# indicator=\"总市值\"; choice of {\"总市值\", \"市盈率(TTM)\", \"市盈率(静)\", \"市净率\", \"市现率\"}\n",
    "# period=\"近一年\"; choice of {\"近一年\", \"近三年\", \"近五年\", \"近十年\", \"全部\"}\n",
    "stock_zh_valuation_baidu_df = ak.stock_zh_valuation_baidu(symbol=\"002304\", indicator=\"市盈率(TTM)\", period=\"近一年\")\n",
    "print(\"A 股估值指标\")\n",
    "print(stock_zh_valuation_baidu_df)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "bt",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
